﻿using System;
using System.Diagnostics;
using System.Runtime.Serialization;

namespace Ping.Core
{
	[DataContract]
	public sealed class StatusResult
		: Result
	{
#if SERVER
		public StatusResult(IServer server)
		{
			Uptime = DateTime.Now - server.Started;
			NumConnections = server.NumConnections;
			NumBlacklistedIPs = server.NumBlacklistedIPs;

			Process p = Process.GetCurrentProcess();
			PagedProcessMemory = p.PagedMemorySize64;
			PagedSystemMemory = p.PagedSystemMemorySize64;
			PeakPagedMemory = p.PeakPagedMemorySize64;
			PeakVirtualMemory = p.PeakVirtualMemorySize64;
			PrivateMemory = p.PrivateMemorySize64;

			NumThreads = p.Threads.Count;
		}
#endif

		[DataMember] public Int64 NonpagedSystemMemory;
		[DataMember] public int NumBlacklistedIPs;
		[DataMember] public int NumConnections;
		[DataMember] public int NumThreads;
		[DataMember] public Int64 PagedProcessMemory;
		[DataMember] public Int64 PagedSystemMemory;
		[DataMember] public Int64 PeakPagedMemory;
		[DataMember] public Int64 PeakVirtualMemory;
		[DataMember] public Int64 PrivateMemory;
		[DataMember] public TimeSpan Uptime;
	}
}